package com.diligent.cloud.sfc.resources.impl;

import com.canny.commons.model.ListResult;
import com.canny.commons.model.ObjectResult;
import com.canny.commons.model.Result;
import com.diligent.cloud.sfc.resources.ProdBatchResource;
import com.diligent.cloud.sfc.service.ProdBatchService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;

import java.security.Principal;

/**
 * ProdBatchResourceImpl class
 *
 * @author xf107278
 * @date 4/2/2020
 */
@RestController
public class ProdBatchResourceImpl implements ProdBatchResource {

    private ProdBatchService prodBatchService;

    public ProdBatchResourceImpl(ProdBatchService prodBatchService) {
        this.prodBatchService = prodBatchService;
    }

    @Override
    public ResponseEntity<Result> updateBatchStatus(String prodBatch, Long mdId, Long systemId, Long orderId, Principal principal) {
        return prodBatchService.cancellationProdBatch(mdId, prodBatch, systemId, orderId, principal);
    }

    @Override
    public ResponseEntity<ObjectResult> getBatch(String machCode, Long systemId, Principal principal) {
        return prodBatchService.getBatch(machCode, systemId, principal);
    }

    @Override
    public ResponseEntity<ObjectResult> getLastOneBatch(String machCode, Long systemId, Principal principal) {
        return prodBatchService.getLastOneBatch(machCode, systemId, principal);
    }

    @Override
    public ResponseEntity<ObjectResult> getLastOneBatchByCart(String machCode, Long systemId, Boolean cart,
                                                              Principal principal) {
        return prodBatchService.getLastOneBatchByCart(machCode, systemId, principal);
    }

    @Override
    public ResponseEntity<ObjectResult> getMatStatisticsConsumeByProdBatch(String startTime, String endTime) {
        return prodBatchService.getMatStatisticsConsumeByProdBatch(startTime, endTime);
    }

    @Override
    public ResponseEntity<ListResult> getProdBatchByMachCode(String machCode, Integer isFinished, Long pageIndex, Long pageSize) {
        return prodBatchService.getProdBatchByMachCode(machCode, isFinished, pageIndex, pageSize);
    }


}
